package com.fmsz.xmly.adapters.anchor;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import com.fmsz.xmly.R;
import com.fmsz.xmly.entitys.anchor.AnchorEntity;
import com.squareup.picasso.Picasso;
import java.util.List;

/**
 * Created by lenovo on 2016/12/7.
 */

public class AnchorContentAdapter extends RecyclerView.Adapter<AnchorContentAdapter.ViewHolder> {
private List<AnchorEntity.ListBean> list;
    private Context context;

    public AnchorContentAdapter(List<AnchorEntity.ListBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.item_anchor_content,parent,false);
        return new ViewHolder(view);
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {
        holder.textView.setText(list.get(position).getNickname());
        Picasso.with(context).load(list.get(position).getSmallLogo()).into(holder.imageView);

    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {
        private ImageView imageView;
        private TextView textView;

        public ViewHolder(View itemView) {
            super(itemView);
            imageView= (ImageView) itemView.findViewById(R.id.anchor_content_iv);
            textView= (TextView) itemView.findViewById(R.id.anchor_content_tv);


        }
    }
}
